<template>
  <div id="app">
    <div id="nav">
      <router-link to="/p1">Home</router-link> |
      <router-link to="/p2">Page2</router-link>|
      <router-link to="/p3">Page3</router-link>
      <router-link to="/layout">layout-l1</router-link>
      <router-link to="/layout/l3">layout-l3</router-link>
    </div>
    <button @click="push">push</button>
    <button @click="replace">replace</button>
    <button @click="go">go</button>
    <router-view/>
  </div>
</template>

<script>
export default {
  methods: {
    push () {
      // this.$router.push('/layout') // 字符串
      this.$router.push({ name: 'l-page1' }) // 对象：router 的 name
    },
    replace () {
      // 不会记录本次历史，替换当前历史
      this.$router.replace('/p1')
    },
    go () {
      // 负数后退，正数前进
      this.$router.go(-1)
    }
  }
}
</script>
